/*
@Author: bevin

@Created on: 2017-01-29 09:45:41
*/

package main

import (
	"fmt"
)

const N = 1000000

func main() {
	maxn := 0
	curmax := 0
	for i := 1; i < N; i++ {
		tmp := getNumofChains(i)
		if tmp > maxn {
			curmax = i
			maxn = tmp
		}
	}
	fmt.Println(curmax)
}

func getNumofChains(num int) int {
	count := 1
	for num != 1 {
		if num%2 == 0 {
			num /= 2
		} else {
			num = 3*num + 1
		}
		count++
	}
	return count
}
